function e(e) {
    return (e = e.toString())[1] ? e : "0" + e;
}

Date.prototype.format = function(e) {
    var t = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        S: this.getMilliseconds()
    };
    for (var r in /(y+)/.test(e) && (e = e.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))), 
    t) new RegExp("(" + r + ")").test(e) && (e = e.replace(RegExp.$1, 1 == RegExp.$1.length ? t[r] : ("00" + t[r]).substr(("" + t[r]).length)));
    return e;
}, Date.prototype.dateAdd = function(e, t) {
    var r = new Date(this.getTime());
    switch (e) {
      case "y":
        r.setFullYear(r.getFullYear() + t);
        break;

      case "m":
        r.setMonth(r.getMonth() + t);
        break;

      case "d":
        r.setDate(r.getDate() + t);
        break;

      case "w":
        r.setDate(r.getDate() + 7 * t);
        break;

      case "h":
        r.setHours(r.getHours() + t);
        break;

      case "n":
        r.setMinutes(r.getMinutes() + t);
        break;

      case "s":
        r.setSeconds(r.getSeconds() + t);
        break;

      case "ms":
        r.setMilliseconds(r.getMilliseconds() + t);
    }
    return r;
}, Date.prototype.dateDiff = function(e, t) {
    var r = this, n = r.getTime(), o = t.getTime(), a = {};
    return a.y = t.getFullYear() - r.getFullYear(), a.q = 4 * a.y + Math.floor(t.getMonth() / 4) - Math.floor(r.getMonth() / 4), 
    a.m = 12 * a.y + t.getMonth() - r.getMonth(), a.ms = t.getTime() - r.getTime(), 
    a.w = Math.floor((o + 3456e5) / 6048e5) - Math.floor((n + 3456e5) / 6048e5), a.d = Math.floor(o / 864e5) - Math.floor(n / 864e5), 
    a.h = Math.floor(o / 36e5) - Math.floor(n / 36e5), a.n = Math.floor(o / 6e4) - Math.floor(n / 6e4), 
    a.s = Math.floor(o / 1e3) - Math.floor(n / 1e3), a[e];
}, String.prototype.toDate = function() {
    return new Date(this.replace(/-/g, "/").replace("T", " "));
}, module.exports = {
    formatTime: function(t) {
        var r = t.getFullYear(), n = t.getMonth() + 1, o = t.getDate(), a = t.getHours(), s = t.getMinutes(), i = t.getSeconds();
        return [ r, n, o ].map(e).join("/") + " " + [ a, s, i ].map(e).join(":");
    },
    inArray: function(e, t, r) {
        var n;
        if (t) {
            if (indexOf) return indexOf.call(t, e, r);
            for (n = t.length, r = r ? r < 0 ? Math.max(0, n + r) : r : 0; r < n; r++) if (r in t && t[r] === e) return r;
        }
        return -1;
    },
    getParam: function(e, t) {
        var r = new RegExp("(^|&)" + t + "=([^&]*)(&|$)"), n = e.substring(1).match(r);
        return null != n ? n[2] : null;
    },
    objToQueryStr: function(e) {
        var t = "";
        for (var r in e) {
            var n = e[r];
            t = t + r + "=" + (n = n instanceof Object ? JSON.stringify(n) : n) + "&";
        }
        return t.substring(0, t.length - 1);
    },
    setBoxChecked: function(e, t) {
        if (e instanceof Array) for (var r in e) e[r].checked = r == t;
    }
};